﻿///////////////////////////////////////////////////////////////////////////
/// File: <FileName>
/// Description: 
///    -  本文件是由代码生成工具自动生成的，如非必要，不要修改，若有新增内容，新建一个partial类进行新增。
///    <Description>
/// Copyright© <DateTime.Now.Year> <Copyright>
/// History:
///     <DateTime.Now>    My.GenCode    Original Version
///////////////////////////////////////////////////////////////////////////
 
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;

using MAF.Common;
using <NameSpace>.Domain.Entities;
using <NameSpace>.Domain.Interfaces;
using <NameSpace>.Business.Service;

namespace <NameSpace>.Web.Controllers
{
    public partial class <ClassName>
    {
        protected <InterfaceName> _this = null;  //new Factory().CreateArticle();
        protected BasePage _page = null;
        
        // 构造方法
        public <ClassName>(BasePage page)
        {
            _page = page;
        }
        
        /// <summary>
        /// <CreateMethodName>
        /// </summary>
        public object <CreateMethodName>()
        {                
            <EntityClassName> info = new <EntityClassName>();
            MAF.Common.ObjectConverter.ToObject<<EntityClassName>>( HttpContext.Current.Request.Form, info );
            object o = _this.<CreateMethodName>(info);
            return o;
        }
        
        /// <summary>
        /// <UpdateMethodName>
        /// </summary>
        public int <UpdateMethodName>()
        {
            <EntityClassName> info = new <EntityClassName>();
            MAF.Common.ObjectConverter.ToObject<<EntityClassName>>( HttpContext.Current.Request.Form, info );
            int i = _this.<UpdateMethodName>(info);
            return i;
        }
        
        /// <summary>
        /// <DeleteMethodName>
        /// </summary>
        public int <DeleteMethodName>()
        {
            <EntityClassName> info = new <EntityClassName>();
            info.Ids = HttpContext.Current.Request.Form["Ids"];
            int i = _this.<DeleteMethodName>( info );
            return i;
        }
        
        /// <summary>
        /// <ReadDetailMethodName>
        /// </summary>
        public <EntityClassName> <ReadDetailMethodName>()
        {
            <EntityClassName> info = new <EntityClassName>();
            MAF.Common.ObjectConverter.ToObject<<EntityClassName>>( HttpContext.Current.Request.QueryString, info );
            info = _this.<ReadDetailMethodName>( info );
            return info;
        }
        
        /// <summary>
        /// <ReadListMethodName>
        /// </summary>
        public IList<<EntityClassName>> <ReadListMethodName>(out PageInfo page)
        {
            HttpContext context = HttpContext.Current;
            <EntityClassName> info = new <EntityClassName>();
            MAF.Common.ObjectConverter.ToObject<<EntityClassName>>( context.Request.QueryString, info );
    
            int currPage; int.TryParse(context.Request.QueryString["Page"], out currPage);
            
            page = new PageInfo(_page.PageSize, currPage);
            page.RecordCount = _this.<ReadCountMethodName>(info);
               
            IList<<EntityClassName>> list = _this.<ReadListMethodName>(info, page.PageSize, page.CurrentPage);
            return list;
        }
    }
}